import {reqbannerlist} from '../../http/api'

//状态
let state = {
    arr:[]
}

//导出数据
let getters = {
    arr(state){
        return state.arr
    }
}

//修改状态
let mutations = {
    changeArr(state,arr){
        state.arr = arr
    }
}

//做异步 做逻辑
let actions = {
    reqBannerArr(context) {
        //发起请求
        reqbannerlist().then(res=>{
            if(res.data.code ===200){
                //修改arr
                let arr = res.data.list ? res.data.list:[]
                    context.commit('changeArr',arr)
            }
        })
    }
}

// 导出
export default {
    state,
    getters, 
    mutations, 
    actions,
    namespaced: true
}